package cn.itcast.bos.action.system;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionContext;

import cn.itcast.bos.domain.system.Menu;
import cn.itcast.bos.service.system.MenuService;
import cn.itcast.bos.utils.BaseAction;

public class MenuAction extends BaseAction<Menu> {
	@Autowired
	private MenuService menuService;

	@Action(value = "menu_list", results = { @Result(name = "success", type = "json") })
	public String findAll() {
		//List<Menu> list = menuService.findAll();
		List<Menu> list = menuService.findByParentMenuIsNull();
		ActionContext.getContext().getValueStack().push(list);
		return SUCCESS;
	}

	@Action(value = "menu_save", results = {
			@Result(name = "success", type = "redirect", location = "pages/system/menu.html") })
	public String save() {
		menuService.save(model);
		return SUCCESS;
	}
}
